package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.dto.BedDto;
import com.zzyl.entity.Bed;
import com.zzyl.entity.RoomType;
import com.zzyl.mapper.BedMapper;
import com.zzyl.service.BedService;
import com.zzyl.vo.BedVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BedServiceImpl implements BedService {

    @Autowired
    private BedMapper bedMapper;

    /**
     * 添加床位
     * @param bedDto
     */
    @Override
    public void addBed(BedDto bedDto) {
        Bed bean = BeanUtil.toBean(bedDto, Bed.class);
        bedMapper.addBed(bean);
    }

    /**
     * 根据id查找床位详情
     * @param id
     */
    @Override
    public BedVo findBedById(Long id) {
        BedVo bedVo = bedMapper.findBedById(id);
        return BeanUtil.toBean(bedVo, BedVo.class);
    }

    /**
     * 修改床位信息
     */
    @Override
    public void updateBed(BedDto bedDto) {
        BeanUtil.toBean(bedDto, Bed.class);
        bedMapper.updateBed(bedDto);
    }

    /**
     * 删除床位
     */
    @Override
    public void deleteBed(Long id) {
        bedMapper.deleteBed(id);
    }
}
